Skip to content

Conversation

@arsenm
Copy link
Contributor

@arsenm arsenm commented Nov 7, 2024

No description provided.

Copy link
Contributor Author

arsenm commented Nov 7, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @arsenm and the rest of your teammates on Graphite Graphite

@arsenm arsenm marked this pull request as ready for review November 7, 2024 00:07
@llvmbot
Copy link
Member

llvmbot commented Nov 7, 2024

@llvm/pr-subscribers-llvm-transforms

Author: Matt Arsenault (arsenm)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/115240.diff

2 Files Affected:

  • (modified) llvm/lib/CodeGen/AtomicExpandPass.cpp (+1)
  • (modified) llvm/test/Transforms/AtomicExpand/X86/expand-atomic-xchg-fp.ll (+22)
diff --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp b/llvm/lib/CodeGen/AtomicExpandPass.cpp
index 1471e3d7cbc29d..439236633c41bc 100644
--- a/llvm/lib/CodeGen/AtomicExpandPass.cpp
+++ b/llvm/lib/CodeGen/AtomicExpandPass.cpp
@@ -498,6 +498,7 @@ AtomicExpandImpl::convertAtomicXchgToIntegerType(AtomicRMWInst *RMWI) {
                                           RMWI->getAlign(), RMWI->getOrdering(),
                                           RMWI->getSyncScopeID());
   NewRMWI->setVolatile(RMWI->isVolatile());
+  copyMetadataForAtomic(*NewRMWI, *RMWI);
   LLVM_DEBUG(dbgs() << "Replaced " << *RMWI << " with " << *NewRMWI << "\n");
 
   Value *NewRVal = RMWI->getType()->isPointerTy()
diff --git a/llvm/test/Transforms/AtomicExpand/X86/expand-atomic-xchg-fp.ll b/llvm/test/Transforms/AtomicExpand/X86/expand-atomic-xchg-fp.ll
index c88671e3bb407f..2341eb05c568c2 100644
--- a/llvm/test/Transforms/AtomicExpand/X86/expand-atomic-xchg-fp.ll
+++ b/llvm/test/Transforms/AtomicExpand/X86/expand-atomic-xchg-fp.ll
@@ -36,3 +36,25 @@ define double @atomic_xchg_f64_as1(ptr addrspace(1) %ptr) nounwind {
   %result = atomicrmw xchg ptr addrspace(1) %ptr, double 4.0 seq_cst
   ret double %result
 }
+
+define double @atomic_xchg_f64_preserve_md(ptr %ptr) nounwind {
+; CHECK-LABEL: @atomic_xchg_f64_preserve_md(
+; CHECK-NEXT:    [[TMP1:%.*]] = load i64, ptr [[PTR:%.*]], align 8, !mmra [[META0:![0-9]+]]
+; CHECK-NEXT:    br label [[ATOMICRMW_START:%.*]]
+; CHECK:       atomicrmw.start:
+; CHECK-NEXT:    [[LOADED:%.*]] = phi i64 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
+; CHECK-NEXT:    [[TMP2:%.*]] = cmpxchg ptr [[PTR]], i64 [[LOADED]], i64 4616189618054758400 seq_cst seq_cst, align 8, !mmra [[META0]]
+; CHECK-NEXT:    [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP2]], 1
+; CHECK-NEXT:    [[NEWLOADED]] = extractvalue { i64, i1 } [[TMP2]], 0
+; CHECK-NEXT:    br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
+; CHECK:       atomicrmw.end:
+; CHECK-NEXT:    [[TMP3:%.*]] = bitcast i64 [[NEWLOADED]] to double
+; CHECK-NEXT:    ret double [[TMP3]]
+;
+  %result = atomicrmw xchg ptr %ptr, double 4.000000e+00 seq_cst, align 8, !mmra !0
+  ret double %result
+}
+
+!0 = !{!1, !2}
+!1 = !{!"foo", !"bar"}
+!2 = !{!"bux", !"baz"}

@arsenm
Copy link
Contributor Author

arsenm commented Nov 13, 2024

ping

@arsenm arsenm merged commit 04d450f into main Nov 13, 2024
13 checks passed
@arsenm arsenm deleted the users/arsenm/atomic-expand-cast-preserve-metadata_split branch November 13, 2024 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants